package com.cdainfo.vaadin;

import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.swing.text.TabableView;

import com.cdainfo.vaadin.container.CDAIndexedContainer;
import com.cdainfo.vaadin.container.CDAIndexedContainer.Columna;
import com.cdainfo.vaadin.event.ColumnShownChangedEvent;
import com.cdainfo.vaadin.event.TablaFiltroEnterEvent;
import com.cdainfo.vaadin.listener.ColumnShownChangedListener;
import com.cdainfo.vaadin.listener.TablaFiltroEnterListener;
import com.vaadin.annotations.AutoGenerated;
import com.vaadin.data.Item;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.event.Action.Handler;
import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.event.ShortcutListener;
import com.vaadin.terminal.Sizeable;
import com.vaadin.ui.AbstractField;
import com.vaadin.ui.AbstractLayout;
import com.vaadin.ui.AbstractSelect.ItemDescriptionGenerator;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Component;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Panel;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.Table.ColumnReorderEvent;
import com.vaadin.ui.Table.ColumnReorderListener;
import com.vaadin.ui.Table.ColumnResizeEvent;
import com.vaadin.ui.Table.ColumnResizeListener;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;

public class TablaFiltro extends CustomComponent implements
		ColumnResizeListener, ColumnReorderListener, ColumnShownChangedListener
		{

	@AutoGenerated
	private VerticalLayout mainLayout;

	@AutoGenerated
	private Panel pnlFiltroTabla;

	@AutoGenerated
	private VerticalLayout lytFiltroTabla;

	@AutoGenerated
	private TableEvento tblContenido;

	@AutoGenerated
	private HorizontalLayout lytFiltro;

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	

	/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */

	/**
	 * 
	 */
	private static final long serialVersionUID = 7594948862715098047L;
	
	private static final int SEPARADOR_COLUMNA = 13;
	private static final int SEPARADOR_TABLA = 20;
	public static final String KEY_INICIAL = " INICIAL";
	public static final String KEY_FINAL = " FINAL";
	private static final String KEY_LAYOUT = "LAYOUT";
	
	private Integer separadorColumna;
	private Integer separadorTabla;
	
	private Map<String, Component> mapDatos;	

	private CDAIndexedContainer container;
	
	private Set<TablaFiltroEnterListener> tablaFiltroEnterListeners;
	
	/*protected static Method LISTENER_METHOD_FILTRO_CHANGED;
	
	static {
		try {
			LISTENER_METHOD_FILTRO_CHANGED = FiltroChangedListener.class
					.getDeclaredMethod("filtroChanged",
							new Class[] { FiltroChangedEvent.class });
		} catch (SecurityException e) {
			throw e;
		} catch (NoSuchMethodException e) {
			throw new RuntimeException("Método filtroChanged no encontrado.",e);
		}
	}*/

	/**
	 * The constructor should first build the main layout, set the composition
	 * root and then do any custom initialization.
	 * 
	 * The constructor will not be automatically regenerated by the visual
	 * editor.
	 */
	public TablaFiltro() {
		this(null);
	}

	public TablaFiltro(CDAIndexedContainer container) {
		this.container = container;
		//this.listaFiltros = new ArrayList<Filtro>();
		buildMainLayout();
		setCompositionRoot(mainLayout);
		
		mapDatos = new HashMap<String, Component>();
		
		tblContenido.setImmediate(true);		
		
		if (container == null) {
			container = new CDAIndexedContainer();
			container.addContainerProperty("nombre", String.class, "Pepe",
					"Nombre", CDAIndexedContainer.TipoComponente.TEXT, true,
					120);
			container.addContainerProperty("fecha", Date.class,
					new Date(), "Fecha",
					CDAIndexedContainer.TipoComponente.DATEPICKER, false, 180);
			container.addContainerProperty("tipo", Double.class, 1.54,
					"Tipo", CDAIndexedContainer.TipoComponente.TEXT, true, 150);

			Item fila = container.addItem(1);
			fila.getItemProperty("nombre").setValue("Pepito");
			fila.getItemProperty("fecha").setValue(new Date());
			fila.getItemProperty("tipo").setValue(2.15);

			fila = container.addItem(2);
			fila.getItemProperty("nombre").setValue("Juan");
			fila.getItemProperty("fecha").setValue(new Date());
			fila.getItemProperty("tipo").setValue(12.54);

			fila = container.addItem(3);
			fila.getItemProperty("nombre").setValue("Lolo");
			fila.getItemProperty("fecha").setValue(new Date());
			fila.getItemProperty("tipo").setValue(35.14);
			
			setContainerDataSource(container);

		}		

		tblContenido.addListener((ColumnResizeListener) this);	
		pnlFiltroTabla.setScrollable(true);
		
		mainLayout.setDebugId("mainLayout");
		pnlFiltroTabla.setDebugId("pnlFiltroTabla");
		lytFiltroTabla.setDebugId("lytFiltroTabla");
		tblContenido.setDebugId("tblContenido");
		lytFiltro.setDebugId("lytFiltro");
	}
	
	@Override
	public void attach() {
		super.attach();
		lytFiltroTabla.setSizeUndefined();
		ordenarTamanhos();
	}
	
	private void ordenarTamanhos()
	{
		mainLayout.setWidth(getWidth(), getWidthUnits());
		pnlFiltroTabla.setWidth(getWidth(), getWidthUnits());	
	}
	
	public void setContainerDataSource(CDAIndexedContainer container) {
		this.container = container;
		lytFiltro.removeAllComponents();
		mapDatos = new HashMap<String, Component>();		
		
		tblContenido.setContainerDataSource(this.container);
		
		List<Columna> columnas = this.container.getColumnas();
		
		Object[] columnasVisibles = new Object[columnas.size()];
		int i = 0;
		for (Columna columna : columnas) {
			columnasVisibles[i++] = columna.getPropertyId();			
		}
		tblContenido.setVisibleColumns(columnasVisibles);
		
		for (Columna columna : columnas) {
			agregarColumna(columna, true);
		}		

		for (Columna columna : this.container.getColumnas()) {
			Object propertyId = columna.getPropertyId();
			tblContenido.setColumnHeader(columna.getPropertyId(), columna.getNombre());
			tblContenido.setColumnWidth(propertyId, (int) columna.getAncho());
			if (columna.isBusquedaPuntual()) {
				Component campo = mapDatos.get(columna.getNombre());
				campo.setWidth(tblContenido.getColumnWidth(propertyId)
						+ getSeparadorColumna(), Sizeable.UNITS_PIXELS);
			} else {
				Component campo = mapDatos.get(columna.getNombre()
						+ KEY_INICIAL);
				campo.setWidth(tblContenido.getColumnWidth(propertyId)
						+ getSeparadorColumna(), Sizeable.UNITS_PIXELS);
				campo = mapDatos.get(columna.getNombre() + KEY_FINAL);
				campo.setWidth(tblContenido.getColumnWidth(propertyId)
						+ getSeparadorColumna(), Sizeable.UNITS_PIXELS);
			}

		}	
		
		
		
	}
	
	public void addListener(TablaFiltroEnterListener listener) {
		if(tablaFiltroEnterListeners == null)
		{
			tablaFiltroEnterListeners = new HashSet<TablaFiltroEnterListener>();
			
			Iterator<String> iter = mapDatos.keySet().iterator();
			Object componente = null;
			while (iter.hasNext()) {
				componente = mapDatos.get(iter.next());
				if(componente instanceof AbstractField )
				{
					break;
				}
			}
			
			if(componente != null)
			{
				((AbstractField) componente).addShortcutListener(new ShortcutListener("", KeyCode.ENTER, null) {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = -2316090032911086252L;

					@Override
					public void handleAction(Object sender, Object target) {
						Map<String, Object>  datos = getValues();
						Iterator<TablaFiltroEnterListener> iterFiltros = tablaFiltroEnterListeners.iterator();
						while (iterFiltros.hasNext()) {
							TablaFiltroEnterListener listener = iterFiltros.next();
							
							TablaFiltroEnterEvent event = new TablaFiltroEnterEvent();
							event.setDatos(datos);
							event.setSender(sender);
							event.setTarget(target);
							event.setTablaFiltro(TablaFiltro.this);
							listener.handleEnterAction(event);
						}
						
						
					}
				});
			}
		}
		tablaFiltroEnterListeners.add(listener);
	}
	
	public void removeListener(TablaFiltroEnterListener listener)
	{
		tablaFiltroEnterListeners.remove(listener);
	}
	
	/*@Override
	public void setWidth(float width, int unit) {
		mainLayout.setWidth(width, unit);
		pnlFiltroTabla.setWidth(width, unit);
		super.setWidth(width, unit);
	}
	
	@Override
	public void setWidth(String width) {
		mainLayout.setWidth(width);
		pnlFiltroTabla.setWidth(width);
		super.setWidth(width);
	}*/
	
	private AbstractField agregarColumna(CDAIndexedContainer.Columna columna,
			boolean agregarLayout) {
		if (columna.isBusquedaPuntual()) {
			AbstractField abstractField = null;
			try {
				switch (columna.getTipoComponente()) {
				case DATEPICKER:
					PopupDateField pdfFecha = new PopupDateField();
					pdfFecha.setData(columna.getPropertyId());
					pdfFecha.setDebugId(columna.getNombre());
					pdfFecha.setInputPrompt(columna.getNombre());
					abstractField = pdfFecha;
					mapDatos.put(columna.getNombre(), pdfFecha);
					return pdfFecha;

				default:
					TextField txtDato = new TextField();
					txtDato.setDebugId(columna.getNombre());
					txtDato.setInputPrompt(columna.getNombre());
					txtDato.setData(columna.getPropertyId());
					abstractField = txtDato;
					mapDatos.put(columna.getNombre(), txtDato);
					return txtDato;
				}
			} finally {
				abstractField.setWidth(columna.getAncho(),
						Sizeable.UNITS_PIXELS);

				if (agregarLayout) {
					lytFiltro.addComponent(abstractField);
					lytFiltro.setComponentAlignment(abstractField,
							new Alignment(9));
				}
			}
		} else {
			VerticalLayout lyt = new VerticalLayout();
			lyt.setImmediate(false);
			lyt.setWidth("-1px");
			lyt.setHeight("-1px");
			lyt.setMargin(false);

			Columna columnaInicial = container.new Columna(
					columna.getPropertyId() + KEY_INICIAL, columna.getNombre()
							+ KEY_INICIAL, columna.getTipoComponente(), true,
					columna.getAncho());

			lyt.addComponent(agregarColumna(columnaInicial, false));

			Columna columnaFinal = container.new Columna(
					columna.getPropertyId() + KEY_FINAL, columna.getNombre()
							+ KEY_FINAL, columna.getTipoComponente(), true,
					columna.getAncho());

			lyt.addComponent(agregarColumna(columnaFinal, false));

			lytFiltro.addComponent(lyt);
			lytFiltro.setComponentAlignment(lyt, new Alignment(9));
			
			mapDatos.put(columna.getNombre() + KEY_LAYOUT, lyt);

		}
		return null;
	}	

	@Override
	public void columnResize(ColumnResizeEvent event) {
		Columna columna = container.getColumna(event.getPropertyId());
		if (columna.isBusquedaPuntual()) {
			Component campo = mapDatos.get(columna.getNombre());
			campo.setWidth(tblContenido.getColumnWidth(event.getPropertyId())
					+ getSeparadorColumna(), Sizeable.UNITS_PIXELS);
		} else {
			Component campo = mapDatos.get(columna.getNombre() + KEY_INICIAL);
			campo.setWidth(tblContenido.getColumnWidth(event.getPropertyId())
					+ getSeparadorColumna(), Sizeable.UNITS_PIXELS);
			campo = mapDatos.get(columna.getNombre() + KEY_FINAL);
			campo.setWidth(tblContenido.getColumnWidth(event.getPropertyId())
					+ getSeparadorColumna(), Sizeable.UNITS_PIXELS);
		}

		int anchoInt = 0;
		for (Columna col : container.getColumnas()) {
			if (!tblContenido.isColumnCollapsed(col.getPropertyId())) {
				anchoInt += tblContenido.getColumnWidth(col.getPropertyId())
						+ getSeparadorColumna();
			}
		}
		anchoInt += getSeparadorTabla();
		tblContenido.setWidth(anchoInt, Sizeable.UNITS_PIXELS);
	}

	public void setColumnReorderingAllowed(boolean allowed)
	{
		tblContenido.setColumnReorderingAllowed(allowed);
		if(allowed)
		{
			tblContenido.addListener((ColumnReorderListener) this);
		}
		else
		{
			tblContenido.removeListener((ColumnReorderListener) this);
		}
		tblContenido.addActionHandler(null);//FIXME
	}
	
	@Override
	public void columnReorder(ColumnReorderEvent event) {
		int con=0;
		for (int i = 0; i < tblContenido.getColumnHeaders().length; i++) {
			String s=tblContenido.getColumnHeaders()[i];
			Columna columna = container.getColumnaPorNombre(s);
			if(columna != null)
			{
				if(!tblContenido.isColumnCollapsed(columna.getPropertyId())){
					Component campo;
					if (columna.isBusquedaPuntual()) {
						campo = mapDatos.get(columna.getNombre());
					}
					else
					{
						campo = mapDatos.get(columna.getNombre() + KEY_LAYOUT);
					}
					lytFiltro.addComponent(campo, con);
					lytFiltro.setComponentAlignment(campo, new Alignment(9));
				}
			}
			con++;
			
		}
	}
	
	public void setColumnCollapsingAllowed(boolean allowed)
	{
		tblContenido.setColumnCollapsingAllowed(allowed);	
		if(allowed)
		{
			tblContenido.addListener((ColumnShownChangedListener) this);	
		}
		else
		{
			tblContenido.removeListener((ColumnShownChangedListener) this);
		}
	}

	@Override
	public void columnShownChanged(ColumnShownChangedEvent event) {
		columnCollapsed();
		int anchoInt=0;
		for (String col : tblContenido.getColumnHeaders()) {
			Columna columna = container.getColumnaPorNombre(col);
			if(columna != null)
			{
				if(!tblContenido.isColumnCollapsed(columna.getPropertyId())){
					anchoInt+=tblContenido.getColumnWidth(columna.getPropertyId())+getSeparadorColumna();
				}
			}
		}
		anchoInt+=getSeparadorTabla();
		tblContenido.setWidth(anchoInt, Sizeable.UNITS_PIXELS);
	}
	
	private void columnCollapsed(){
		int con=0;
		for (int i = 0; i < tblContenido.getColumnHeaders().length; i++) {
			String s=tblContenido.getColumnHeaders()[i];
			Columna columna = container.getColumnaPorNombre(s);
			if(columna!=null)
			{
				if(!tblContenido.isColumnCollapsed(columna.getPropertyId())){				
					Component campo;
					if (columna.isBusquedaPuntual()) {
						campo = mapDatos.get(columna.getNombre());
					}
					else
					{
						campo = mapDatos.get(columna.getNombre() + KEY_LAYOUT);
					}
					lytFiltro.addComponent(campo, con);
					lytFiltro.setComponentAlignment(campo, new Alignment(9));
					con++;
				}else{
					Component campo;
					if (columna.isBusquedaPuntual()) {
						campo = mapDatos.get(columna.getNombre());
					}
					else
					{
						campo = mapDatos.get(columna.getNombre() + KEY_LAYOUT);
					}
					lytFiltro.removeComponent(campo);
				}
			}
		}
	}
	
	public Map<String, Object> getValues()
	{
		return getValuesFromComponent(lytFiltro);
	}
	
	private Map<String, Object> getValuesFromComponent(AbstractLayout layout)
	{
		Map<String, Object> map = new HashMap<String, Object>();
		Iterator<Component> componentes = layout.getComponentIterator();
		while(componentes.hasNext())
		{
			Component component = componentes.next();
			if(component instanceof AbstractField)
			{
				AbstractField campo = (AbstractField)component;
				map.put((String)campo.getData(), campo.getValue());
			}
			else if (component instanceof AbstractLayout)
			{
				map.putAll(getValuesFromComponent((AbstractLayout)component));
			}
		}
		return map;
	}
	
	/*public void addListener(FiltroChangedListener listener)
	{
		addListener(FiltroChangedEvent.class, listener,
				LISTENER_METHOD_FILTRO_CHANGED);
	}
	
	public void removeListener(FiltroChangedListener listener) {
		removeListener(FiltroChangedEvent.class, listener,
				LISTENER_METHOD_FILTRO_CHANGED);
	}
	
	protected void fireFiltroChanged() {
		fireEvent(new FiltroChangedEvent(this));
	}*/
	
	public void addListener(ValueChangeListener listener)
	{
		tblContenido.addListener(listener);
	}
	
	public void removeListener(ValueChangeListener listener)
	{
		tblContenido.removeListener(listener);
	}
	
	public void setSelectable(boolean selectable)
	{
		tblContenido.setSelectable(selectable);
	}
	
	public boolean isSelectable()
	{
		return tblContenido.isSelectable();
	}
	
	public void setMultiSelect(boolean selectable)
	{
		tblContenido.setMultiSelect(selectable);
	}
	
	public boolean isMultiSelect()
	{
		return tblContenido.isMultiSelect();
	}
	
	@Override
	public void setImmediate(boolean selectable)
	{
		tblContenido.setImmediate(selectable);
	}
	
	@Override
	public boolean isImmediate()
	{
		return tblContenido.isImmediate();
	}

	public Object getValue() {
		return tblContenido.getValue();
	}

	public void addActionHandler(Handler handler) {
		tblContenido.addActionHandler(handler);
	}

	public void removeAllActionHandlers() {
		tblContenido.removeAllActionHandlers();
	}
	
	public void requestRepaintTable() {
		tblContenido.requestRepaint();
	}
	
	/*
	tblBandejaTrabajo.setSelectable(true);
		tblBandejaTrabajo.setMultiSelect(true);
		tblBandejaTrabajo.setImmediate(true);
	 * */
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see com.vaadin.ui.Table#changeVariables(java.lang.Object, java.util.Map)
	 
	@Override
	public void changeVariables(Object source, Map<String, Object> variables) {
		super.changeVariables(source, variables);

		if (variables.containsKey("collapsedcolumns")) {
			fireColumnShowChanged();
		}

		if (variables.containsKey("columnorder")) {
			fireColumnOrderChanged();
		}

		if (variables.containsKey("sortcolumn")
				|| variables.containsKey("sortascending")) {
			fireColumnSortChanged();
		}

	}*/

	private int getSeparadorColumna() {
		if(separadorColumna == null)
		{
			return SEPARADOR_COLUMNA;
		}
		return separadorColumna;
	}

	public void setSeparadorColumna(int separadorColumna) {
		this.separadorColumna = separadorColumna;
	}

	private int getSeparadorTabla() {
		if(separadorTabla == null)
		{
			return SEPARADOR_TABLA;
		}
		return separadorTabla;
	}

	public void setSeparadorTabla(int separadorTabla) {
		this.separadorTabla = separadorTabla;
	}

	public void setItemDescriptionGenerator(
			ItemDescriptionGenerator itemDescriptionGenerator) {
		tblContenido.setItemDescriptionGenerator(itemDescriptionGenerator);
	}

	public Item getItem(Object itemId) {
		return tblContenido.getItem(itemId);
	}

	public void setValue(Object object) {
		tblContenido.setValue(object);
	}

	public void setNullSelectionAllowed(boolean nullSelectionAllowed)
	{
		tblContenido.setNullSelectionAllowed(nullSelectionAllowed);
	}
	
	public void setNullSelectionItemId(Object nullSelectionItemId)
	{
		tblContenido.setNullSelectionItemId(nullSelectionItemId);
	}
	
	public Collection<?> getItemIds()
	{
		return tblContenido.getItemIds();
	}

	@AutoGenerated
	private VerticalLayout buildMainLayout() {
		// common part: create layout
		mainLayout = new VerticalLayout();
		mainLayout.setImmediate(false);
		mainLayout.setWidth("-1px");
		mainLayout.setHeight("100%");
		mainLayout.setMargin(false);
		
		// top-level component properties
		setWidth("-1px");
		setHeight("100.0%");
		
		// pnlFiltroTabla
		pnlFiltroTabla = buildPnlFiltroTabla();
		mainLayout.addComponent(pnlFiltroTabla);
		mainLayout.setExpandRatio(pnlFiltroTabla, 1.0f);
		
		return mainLayout;
	}

	@AutoGenerated
	private Panel buildPnlFiltroTabla() {
		// common part: create layout
		pnlFiltroTabla = new Panel();
		pnlFiltroTabla.setImmediate(false);
		pnlFiltroTabla.setWidth("-1px");
		pnlFiltroTabla.setHeight("100.0%");
		
		// lytFiltroTabla
		lytFiltroTabla = buildLytFiltroTabla();
		pnlFiltroTabla.setContent(lytFiltroTabla);
		
		return pnlFiltroTabla;
	}

	@AutoGenerated
	private VerticalLayout buildLytFiltroTabla() {
		// common part: create layout
		lytFiltroTabla = new VerticalLayout();
		lytFiltroTabla.setImmediate(false);
		lytFiltroTabla.setWidth("-1px");
		lytFiltroTabla.setHeight("100.0%");
		lytFiltroTabla.setMargin(false);
		
		// lytFiltro
		lytFiltro = new HorizontalLayout();
		lytFiltro.setImmediate(false);
		lytFiltro.setWidth("-1px");
		lytFiltro.setHeight("-1px");
		lytFiltro.setMargin(false);
		lytFiltroTabla.addComponent(lytFiltro);
		
		// tblContenido
		tblContenido = new TableEvento();
		tblContenido.setImmediate(false);
		tblContenido.setWidth("-1px");
		tblContenido.setHeight("100.0%");
		lytFiltroTabla.addComponent(tblContenido);
		lytFiltroTabla.setExpandRatio(tblContenido, 1.0f);
		
		return lytFiltroTabla;
	}
	
	/*public List<Filtro> getListaFiltros() {
		return listaFiltros;
	}

	public void setListaFiltros(List<Filtro> listaFiltros) {
		this.listaFiltros = listaFiltros;
	}*/
}
